/*
 * TouchSensor.java
 *
 * Created on May 31, 2008, 11:34 PM
 *
 * index:
 * 0 -> PRESSED/UNPRESSED
 */
package org.gunncs.actoriface;

import com.sun.spot.sensorboard.io.IInputPin;
import java.io.*;

/**
 *
 * @author Anandg
 */
public class TouchSensor extends Sensor {

    public static final double PRESSED = 1.0;
    public static final double UNPRESSED = 0.0;
    private IInputPin pin;

    /** Creates a new instance of TouchSensor */
    public TouchSensor(IInputPin p) {
        pin = p;
    }

    public String getName() {
        return "TouchSensor";
    }

    public int getID() {
        return 7;
    }

    public synchronized void update(Thread daemon) {  //Daemon Thread call only
        double[] d = new double[2];
        if (pin.isLow()) {
            d[0] = PRESSED;
        } else {
            d[0] = UNPRESSED;
        }
        d[1] =(double) Simulator.time();
        setState(d);
    }
}
